<template>
	<!-- 工地列表 -->
	<div>
		<Card>
			监理列表<Icon type="ios-arrow-forward" /> 工地列表
		</Card>
		<Card>
			<!-- 用户信息列表 -->
			<Table border :columns="columns1" :data="siteList"></Table>
			<!-- 分页 -->
			<br /><br />
			<div style="text-align: center;">
				<Page :total="total" show-elevator @on-change="changeUser" />
			</div>
		</Card>
	</div>
</template>

<script>
	import path from '@/api/path.js';
	let url = path.url;
	import axios from '@/libs/api.request';
	export default {
		data(){
			return {
				columns1: [
					{
						title: '工地编号',
						key: 'id',
						width: 100,
						align: 'center'
					},
					{
						title: '小区图片',
						key: 'name',
						width: 100,
						align: 'center'
					},
					{
						title: '小区地址',
						key: 'userPicture',
						width: 100,
						align: 'center',
						columns: {
							'width': '50px'
						},
						render: (h, params) => {
							return h('div', [
								h('img', {
									attrs: {
										src: params.row.userPicture
									},
									style: {
										width: '40px',
										height: '40px'
									}
								}),
							]);
						}
					},
					{
						title: '开工时间',
						key: 'mobile',
						width: 200,
						align: 'center'
					},
					{
						title: '竣工时间',
						key: 'userIntroduce',
						align: 'center'
					},
					{
						title: '操作',
						key: 'action',
						width: 250,
						align: 'center',
						render: (h, params) => {
							return h('div', [
								h('Button', {
									props: {
										type: 'primary',
										size: 'small'
									},
									style: {
										marginRight: '10px'
									},
									on: {
										click: (e) => {
											this.goDetail(params.row);
										}
									}
								}, '详情'),
								h('Button', {
									props: {
										type: 'error',
										size: 'small'
									},
									on: {
										click: () => {
											this.delect(params.row)
										}
									}
								}, '删除')
							]);
						}
					}
				],
				siteList: [],
				id: this.$route.query.id,
				total: 0,
				page: 1
			}
		},
		methods: {
			getsiteList() {
				axios.request({
					url: `${url}supervision/getSupervisionSiteList`,
					method: 'post',
					data: {
						id: this.id,
						page: this.page
					}
				}).then(res => {
					if (res.data.status == 1) {
						this.siteList = res.data.content.data;
						this.total = res.data.content.total;
					} else {
						throw '获取监理师列表失败！'
					}
				})
			},
			changeUser(idx) {
				this.page = idx;
				this.getsiteList();
			}
		},
		created(){
			this.getsiteList();
		}
	}
</script>

<style>

</style>
